package com.blockmeta.bbs.businesslibrary.baselist;

import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import java.util.HashMap;

import io.reactivex.Flowable;

public abstract class BaseListModelImpl<S extends  BaseBean> extends BaseModel<S> implements  BaseListModel {
    public int PAGE = 1;
    public BaseListModel.LoadComplete loadListeners;
    public Boolean isMore = true;

    @Override
    public void getMoreData(RxAppCompatActivity context) {
        PAGE ++;
        isMore = true;
        PostParams(context);
    }

    @Override
    public void getRefreshDta(RxAppCompatActivity context) {
        PAGE = 1;
        isMore = false;
        PostParams(context);

    }

    @Override
    public void showNetError() {

    }

    @Override
    public void showDataError() {

    }

    @Override
    public void loadComplete(LoadComplete loadComplete) {
        if(loadListeners == null){
            loadListeners = loadComplete;
        }
    }

    @Override
    public void FailedOperation(Throwable e) {

    }

    @Override
    public void SuccessOperation(BaseBean o) {

    }

    @Override
    public HashMap<String, String> getParams() {
        clearHashMap();
        mParams.put("page", String.valueOf(PAGE));
        return mParams;
    }

    @Override
    public Flowable<S> ServiceParams(HashMap<String, String> params) {
        return Flowable.never();
    }

}
